import axios from 'axios'
import * as constants from './constants'
const changeDetail = (title, content) => {
  return {
    type: constants.CHANGE_DETAIL,
    title,
    content,
  }
}

export const getDetail = (id) => {
  return (dispatch) => {
    axios.get('http://localhost:5500/data/detail.json?id='+id).then(({ data }) => {
      const action = changeDetail(data.title, data.content)
      dispatch(action)
    })
  }
}
